package com.northpool.operator.common.algorithm;

public class SystemWrapper {
    private static Runnable exitAction = null;
    private static int exitStatus = -1;

    public static void setExitAction(Runnable action) {
        exitAction = action;
    }

    public static void exit(int status) {
        exitStatus = status;
        if (exitAction != null) {
            exitAction.run();
        } else {
            System.exit(status);
        }
    }

    public static int getExitStatus() {
        return exitStatus;
    }
}
